<?php
// +----------------------------------------------------------------------
// | ManniuRead
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://manniuyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: heitao <read@manniuyun.com>
// +----------------------------------------------------------------------

namespace app\admin\validate;

use think\Validate;

class Admin extends Validate{

    protected $rule = [
        'username' 	=> ['require', 'unique'	=>'admin', 	'min'=>6, 'max'		=>20],
        'password' 	=> ['require', 'min'	=>6, 		'max'=>20],
        'name'      => ['require'],
        'phone' 	=> ['require', 'unique'	=>'admin', 	'number', 'length'	=>11],
        'email' 	=> ['require', 'unique'	=>'admin', 	'email'],
    ];

    protected $message  =   [
        'username.require' 	=> '用户名不能为空',
        'username.unique' 	=> '用户名已存在',
        'username.min' 		=> '用户名长度不能小于6个字符',
        'username.max' 		=> '用户名长度不能大于20个字符',

        'name.require'      => '姓名不能为空',

        'password.require' 	=> '密码不能为空',
        'password.min' 		=> '密码长度不能小于6个字符',
        'password.max' 		=> '密码长度不能大于20个字符',

        'phone.require' 	=> '手机号不能为空',
        'phone.unique' 		=> '手机号已存在',
        'phone.number' 		=> '手机号必须为数字',
        'phone.length' 		=> '手机号必须为11位',

        'email.require' 	=> '邮箱不能为空',
        'email.unique' 		=> '邮箱已存在',
        'email.email' 		=> '邮箱格式错误',
    ];

    protected $scene = [
        'add'   => [
            'username',
            'password',
            'name',
            'phone' => ['unique'=>'admin','number','length'=>11],
            'email'=>['unique'=>'admin','email'],
        ],
        'edit'  => [
            'password'  => ['min'=>6,'max'=>20],
            'phone'     => ['number','length'=>11],
            'email'     => ['email'],
        ],
    ];

}